// =====================================================================================
// 
//       Filename:  main.cpp
// 
//    Description:  
// 
//        Version:  1.0
//        Created:  30.09.2011 16:37:00
//       Revision:  none
//       Compiler:  g++
// 
//         Author:  Dmitriy Serdyuk (), serdyuk.dmitriy@gmail.com
//        Company:  
// 
// =====================================================================================


#include <cstdio>

int** create_array1(int n, int m) {
    int **arr = new int*[n];
    for (int j = 0; j < m; ++j) {
        arr[j] = new int[m];
    }
    return arr;
}

int** create_array2(int n, int m) {
    int **arr = new int*[n];
    arr[0] = new int[n * m];
    for (int i = 1; i < m; ++i) {
        arr[i] = arr[0] + n * i;
    }
    return arr;
}

void delete_array1(int **arr, int /*n*/, int m) {
    for (int j = 0; j < m; ++j) {
        delete[] arr[j];
    }
    delete[] arr;
}

void delete_array2(int ** arr, int /*n*/, int /*m*/) {
    delete[] arr[0];
    delete[] arr;
}

int main(int argc, char *argv[]) {
    int n = 1000000;
    int m = 100000;
    
    int **arr;
    if (argc > 1) {
        arr = create_array1(n, m);
        delete_array1(arr, n, m);
    } else {
        arr = create_array2(n, m);
        delete_array2(arr, n, m);
    }


    return 0;
}

